package com.iteaj.iot.client;

import com.iteaj.network.config.ConnectProperties;
import org.springframework.boot.context.properties.ConfigurationProperties;

@ConfigurationProperties(prefix = "iot.client")
public class ClientProperties {

    /**
     * netty 线程组数量
     */
    private short threadNum = 3;

    /**
     * 应用程序客户端代理配置
     */
    private ClientProxy proxy;

    /**
     * MQTT Broker服务配置
     */
    private MqttClientConfig mqtt;

    public static class ClientProxy extends ConnectProperties {

        /**
         * 代理客户端编号(默认uuid)
         */
        private String deviceSn;

        /**
         * 报文最大长度
         */
        private int maxFrameLength = 1024 * 1024;

        /**
         * 心跳周期(秒)
         */
        private int heartPeriod = 60;

        /**
         * 断开重连时间周期(秒)
         */
        private long reconnect = 30;

        public int getHeartPeriod() {
            return heartPeriod;
        }

        public void setHeartPeriod(int heartPeriod) {
            this.heartPeriod = heartPeriod;
        }

        public String getDeviceSn() {
            return deviceSn;
        }

        public void setDeviceSn(String deviceSn) {
            this.deviceSn = deviceSn;
        }

        public long getReconnect() {
            return reconnect;
        }

        public void setReconnect(long reconnect) {
            this.reconnect = reconnect;
        }

        public int getMaxFrameLength() {
            return maxFrameLength;
        }

        public void setMaxFrameLength(int maxFrameLength) {
            this.maxFrameLength = maxFrameLength;
        }
    }

    public static class MqttClientConfig {

        /**
         * Broker主机端口
         */
        private short port;
        /**
         * Broker主机地址
         */
        private String host;

        public short getPort() {
            return port;
        }

        public void setPort(short port) {
            this.port = port;
        }

        public String getHost() {
            return host;
        }

        public void setHost(String host) {
            this.host = host;
        }
    }

    public ClientProxy getProxy() {
        return proxy;
    }

    public void setProxy(ClientProxy proxy) {
        this.proxy = proxy;
    }

    public MqttClientConfig getMqtt() {
        return mqtt;
    }

    public void setMqtt(MqttClientConfig mqtt) {
        this.mqtt = mqtt;
    }

    public short getThreadNum() {
        return threadNum;
    }

    public void setThreadNum(short threadNum) {
        this.threadNum = threadNum;
    }
}
